<template>
    <div>
        <div class="cons">
            <div class="jx-con">
                <div class="jx-1" v-if="newsList.length > 0">
                    <router-link
                        :to="{
                            path: '/jxdec',
                            query: { id: item.id, parId: param.id },
                        }"
                        v-for="(item, index) in newsList"
                        :key="index"
                    >
                        <img :src="prefixUrl + item.coverImageUrl" />
                        <span>
                            <p>{{ item.title }}</p>
                            <p v-if="item.status == 0">未开始</p>
                            <p v-if="item.status == 1">评审中</p>
                            <p v-if="item.status == 2">已结束</p>
                        </span>
                        <p>
<!--                            申报时间：{{ item.startTime | pattime }} —-->
<!--                            {{ item.endTime | pattime }}-->
                        </p>
                        <p>{{ item.createTime | angtime }}</p>
                    </router-link>
                </div>
                <div class="jx-1" v-else>
                    <p>暂无数据</p>
                </div>

                <div class="news-page">
                    <el-pagination
                        background
                        layout="prev, pager, next"
                        :total="totalSum"
                        :page-size="sizeSum"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                    ></el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import _ from "underscore";
import moment from "moment";
export default {
    filters: {
        pattime(value) {
            if (value) {
                return value.slice(0, 10);
            }
        },
        angtime(value) {
            if (value) {
                return moment(value).format("YYYY-MM-DD");
            }
        },
    },
    data() {
        return {
            prefixUrl: "",
            totalSum: 0,
            sizeSum: 30,
            newsList: [],
        };
    },
    props: {
        param: {
            type: Object,
        },
    },
    created() {
        this.prefixUrl = this.$store.state.user.imgUrl;

        if (this.param) {
            this.getSsglList(1);
        }
        // this.getpageAwardList(1, this.navList[2]);
        // this.type = this.navList[2];
    },
    watch: {
        param: {
            handler(val, oldVal) {
                this.getSsglList(1);
            },
            deep: true,
        },
    },
    mounted() {},
    methods: {
        async getSsglList(val) {
            const data = {
                currentPage: val,
                pageSize: 10,
                rootId: this.param.id,
            };
            const res = await this.$store.dispatch("news/getQyzzList", data);
            console.log(res.list[0])
            this.totalSum = res.totalCount;
            this.newsList = res.list;
        },
        async getpageAwardList(curIndex, type) {
            const data = { type: type, currentPage: curIndex, pageSize: 4 };
            const res = await this.$store.dispatch(
                "access/getpageAwardList",
                data
            );
            this.totalSum = res.totalCount;
            this.newsList = res.list;
            // console.log(res);
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            this.getpageAwardList(val);
        },
    },
};
</script>

<style scoped>
@import "./jiangxiang.css";
</style>
